package com.css.test.proxy;


import java.lang.reflect.Proxy;

/**
 * <p>
 * -
 * </p>
 *
 * @author css
 * @since 2020/7/5
 */
public class Main {
    public static void main(String[] args) {
        test1();
//        test2();
    }

    public static void test1() {
        final TestProxy mapperProxy = new TestProxy();
//        Proxy.newProxyInstance(mapperInterface.getClassLoader(), new Class[]{mapperInterface}, mapperProxy);
        TestInterface proxy = (TestInterface) Proxy.newProxyInstance(TestInterface.class.getClassLoader(), new Class[]{TestInterface.class}, mapperProxy);
        String test = proxy.test();
        System.out.println(test);
    }

    public static void test2() {
        TestInterfaceImpl testInterface = new TestInterfaceImpl();
        final TestProxyIn mapperProxy = new TestProxyIn(testInterface);
//        Proxy.newProxyInstance(mapperInterface.getClassLoader(), new Class[]{mapperInterface}, mapperProxy);
        TestInterface proxy = (TestInterface) Proxy.newProxyInstance(testInterface.getClass().getClassLoader(), testInterface.getClass().getInterfaces(), mapperProxy);
        String test = proxy.test();
        System.out.println(test);
    }
}
